<template>
      <div class="programme_w">
    <div class="programme_h">
      <div class="new_calendar_btn" @click.stop.prevent="newCalendarClick(1)">
        新建日程
      </div>
      <div class="head_date">
        <div class="today" @click="initToday" :class="{
                    active:
                      new Date(days[currentDayIndex].day).toDateString() ===
                      new Date().toDateString(),
                  }">
          今天
        </div>
        <div class="b_month_last" @click="pickPre(currentYear, currentMonth)">
          <span></span>
        </div>
        <div class="b_month_next" @click="pickNext(currentYear, currentMonth)">
          <span></span>
        </div>
        <div>
          {{ currentYear }}年{{ currentMonth }}月{{
                    currentDay
                  }}日星期{{ weekKV[currentWeek] }}
        </div>
      </div>
    </div>
    <div class="programme_m">
      <div class="programme_m_l">
        <div class="programme_date">
          <div class="p_date_tab">
            <div class="p_year">
              {{ currentYear }}年{{ currentMonth }}月
            </div>
            <div class="p_date_t_w">
              <span class="month_last" @click="pickPre(currentYear, currentMonth)"></span>
              <span class="month_next" @click="pickNext(currentYear, currentMonth)"></span>
            </div>
          </div>
          <div class="p_date">
            <div class="p_week_w">
              <ul>
                <li>一</li>
                <li>二</li>
                <li>三</li>
                <li>四</li>
                <li>五</li>
                <li>六</li>
                <li>日</li>
              </ul>
            </div>
            <div class="date_list_wrap">
              <ul class="days">
                <li v-for="(dayobject, index) in days" :key="'day_' + index" @click="daysClick(dayobject, index)">
                  <!--本月-->
                  <!--如果不是本月  改变类名加灰色-->
                  <div class="day_radius" :class="{ active: currentDayIndex == index }">
                    <span v-if="
                                dayobject.day.getMonth() + 1 != currentMonth
                              " class="other-month">{{
                                new Date(dayobject.day).toDateString() ===
                                new Date().toDateString()
                                  ? "今"
                                  : dayobject.day.getDate()
                              }}</span>
                    <!--如果是本月  还需要判断是不是这一天-->
                    <span v-else>
                      <!--今天  同年同月同日-->
                      <span v-if="
                                  dayobject.day.getFullYear() ==
                                    new Date().getFullYear() &&
                                  dayobject.day.getMonth() ==
                                    new Date().getMonth() &&
                                  dayobject.day.getDate() ==
                                    new Date().getDate()
                                " class="active">{{
                                  new Date(dayobject.day).toDateString() ===
                                  new Date().toDateString()
                                    ? "今"
                                    : dayobject.day.getDate()
                                }}</span>
                      <span v-else>{{ dayobject.day.getDate() }}</span>
                    </span>
                    <span class="day_mask" v-if="dayobject.schedule.length > 0" :class="{ active: currentDayIndex == index }"></span>
                  </div>
                </li>
              </ul>
            </div>
          </div>
        </div>
        <div class="schedule_time_wrap">
          <div class="schedule_time_item" v-for="(item, index) in programmeTimeList" :key="'schedule_time' + index">
            <div class="schedule_time">{{ item.time }}</div>
            <div class="schedule_details">
              <div class="schedule_task" v-for="(value, key) in item.schedule" :key="'schedule_' + key" @click.stop.prevent="scheduleSel(value)">
                {{ value.THEME }}
              </div>
            </div>
          </div>
        </div>
      </div>
      <div class="programme_m_r">
        <div class="schedule_head">日程列表</div>
        <div class="schedule_list">
          <div class="schedule_item" v-for="(item, index) in newScheduleList" @click.stop.prevent="scheduleSel(item)" :key="'schedule_' + index">
            <div class="schedule_title">
              <span></span>
              <div>{{ item.THEME }}</div>
            </div>
            <div class="schedule_time">{{ item.STARTTIME }}</div>
          </div>
        </div>
      </div>
    </div>
  </div>
</template>
           
<script>
//  initToday   currentYear currentMonth  currentDay  weekKV currentWeek
export default {
  props: [
    "days",
    "currentDayIndex",
    "currentYear",
    "currentMonth",
    "currentDay",
    "weekKV",
    "currentWeek",
    "programmeTimeList",
    "newScheduleList",
  ],
  methods: {
    scheduleSel(value) {
      this.$emit("scheduleSel", value);
    },
    pickPre(currentYear, currentMonth) {
      this.$emit("pickPre", currentYear, currentMonth);
    },
    pickNext(currentYear, currentMonth) {
      this.$emit("pickNext", currentYear, currentMonth);
    },
    daysClick(dayobject, index) {
      this.$emit("daysClick", dayobject, index);
    },
    initToday() {
      this.$emit("initToday");
    },
    newCalendarClick(type) {
      this.$emit("newCalendarClick", type);
    },
  },
};
</script>
<style scoped>
</style>